package idao.engine;

import idao.ConnectionManager;
import idao.DaoRuntimeException;

import java.sql.Connection;
import java.sql.SQLException;

import javax.sql.DataSource;

class DataSourceConnectionManager implements ConnectionManager
{

    private DataSource ds;

    DataSourceConnectionManager(DataSource ds)
    {
        this.ds = ds;
    }

    public Connection getConnection() throws DaoRuntimeException
    {
        try {
            return ds.getConnection();
        } catch (SQLException e) {
            throw new DaoRuntimeException("Can not get SQL connection.", e);
        }
    }

    public void returnConnection(Connection connection) throws DaoRuntimeException
    {
        // TODO if we should interactive with Tx at here?
    }

}
